<?php
declare (strict_types = 1);

namespace app\admin\controller;

use app\common\controller\Backend;
use hg\apidoc\annotation as Apidoc;

/**
 * 系统配置
 * @Apidoc\Group("base")
 * @package app\admin\controller
 */
class Config extends Backend
{
    /**
     * 初始化参数
     * @author 贾二小
     * @since 2021/7/3
     */
    public function initialize()
    {
        $this->config = [
            'name'=>'系统配置',
            'table_name'=>'config',//表名
            'table_alias' => 'a',//别名
            'table_field'=>'*',//显示默认字段
            'form_field' => 'id,name,code,value,sys_flag,group_code,remark',//表单字段，没有设置则默认为显示字段默认是不能有*和.)
            'form_validated1' => [
                'name' => ['msg' => '名称为空', 'regex' => false, 'pcre' => '',],
                'code' => ['msg' => 'code为空', 'regex' => false, 'pcre' => '',],
            ],//表单验证
            'form_validated2' => ['code'],//重复验证
            'search_table'=> null,//关联表时，需要重写
            'is_limit'=> true,//是否分页显示
            'search_field' => 'id,name,code,value,sys_flag,group_code,remark,status,create_user_id,create_date,update_user_id,update_date',//查询表格字段
            'search_param'=>[
                ['field' => 'name', 'type' => '=', 'param'=> 'name'],
                ['field' => 'code', 'type' => '=', 'param'=> 'code'],
            ],//查询表格条件
            'is_delete'=> true,//是否假删除
            'id_validated' => [
                'id' => ['msg' => 'ID不能为空', 'regex' => false, 'pcre' => '',],
            ],//表单验证
        ];
        parent::initialize();
    }

    /**
     * @Apidoc\Title("系统配置编辑/保存")
     * @author 贾二小
     * @since 2021/7/21
     */
    public function save()
    {
        //清空配置参数缓存
        cache('config_data',null);
        parent::save(); // TODO: Change the autogenerated stub
    }

}